package view;

import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Magnum
 */
public class MainFrame extends JFrame
{

    private final LoginPanel loginPanel;
    private GridBagLayout gridbagLayout;
    private final JPanel currentPanel;
    private MainPanel mainPanel;
    private final DetailedPanel detailedPanel;
    private final CardLayout cl;

    public MainFrame() throws IOException
    {
        super("MiljöBoven");

        //gridbagLayout = new GridBagLayout();
        currentPanel = new JPanel();
        //layout
        cl = new CardLayout();

        loginPanel = new LoginPanel();
        mainPanel = new MainPanel();
        detailedPanel = new DetailedPanel();

        JFrame();

        currentPanel.setLayout(cl);

        currentPanel.add(loginPanel, "1");
        currentPanel.add(mainPanel, "2");
        currentPanel.add(detailedPanel, "3");

        add(currentPanel);

        cl.show(currentPanel, "1");

    }

    public void JFrame()
    {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setResizable(false);
        setPreferredSize(new Dimension(1024, 768));
        pack();
        setVisible(true);
        setLocationRelativeTo(null);
    }

    public void showLoginPanel()
    {
        cl.show(currentPanel, "1");
        setPreferredSize(new Dimension(1024, 768));
        pack();
        setLocationRelativeTo(null);
    }

    public void showMainPanel()
    {
        cl.show(currentPanel, "2");
        setPreferredSize(new Dimension(1024, 768));
        pack();
        setLocationRelativeTo(null);
    }

    public void showDetailedPanel()
    {
        //detailedPanel.updatePanel(null, null, model.User.Type.COORDINATOR, null, 0, model.User.getEditingRights());
        cl.show(currentPanel, "3");
        setPreferredSize(new Dimension(1024, 768));
        pack();
        setLocationRelativeTo(null);
    }

    public void setMainPanel(MainPanel mainPanel)
    {
        this.mainPanel = mainPanel;
    }

    public LoginPanel getLoginPanel()
    {
        return loginPanel;
    }

    public JPanel getCurrentPanel()
    {
        return currentPanel;
    }

    public MainPanel getMainPanel()
    {
        return mainPanel;
    }

    public DetailedPanel getDetailedPanel()
    {
        return detailedPanel;
    }
}
